import React, { useState, useEffect, useCallback, useRef } from 'react';
import { Button, Divider, Popconfirm, Modal, Input, message } from 'antd';
import { useHistory } from 'react-router-dom';
import { LogoutOutlined, HomeOutlined, LoadingOutlined, RollbackOutlined, AuditOutlined, DeleteColumnOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import {
  openNotification_util, checkdatavalid_util_formdata, fetchsync_util,
  resultdata_to_formdata, addkey_for_mxdata,
  use_dict_byzdmc,
  use_olreport_bybbbm,
  combile_mxdata_mxcol_util,
  convertISODateTimeToYYYYMMDD,
  view_item_util,
} from '../util/util.js'
import Customfielditem_hook from '../newmes/customfielditem_hook.js'
import moment from 'moment'
import 'moment/locale/zh-cn'
import Gys_ghmx_hook from './gys_ghmx_hook.js';
import Gys_zzmx_hook from './gys_zzmx_hook.js';
import Gys_sqmx_hook from './gys_sqmx_hook.js';
import Gys_yhmx_hook from './gys_yhmx_hook.js';
import Gys_kpmx_hook from './gys_kpmx_hook.js';
import { SaveOutlined } from '@ant-design/icons';
import logo from '../../../img/shipSRM/chlogo.png'
import { use_gys_initformdata, use_gys_view_initformdata, use_gys_ghmx_column_initformdata, use_gys_zzsz_column_initformdata, use_gys_yhmx_column_initformdata, use_gys_sqmx_column_initformdata, use_gys_kpmx_column_initformdata } from '../gyszx/use_gyszx_config.js';
moment.locale('zh-cn')
var storage = window.localStorage;
import useStore from '../../useStore.js'
import { dropByCacheKey } from 'react-router-cache-route'
import { useLatest } from 'ahooks';
import { v4 as uuidv4 } from 'uuid';


const Gys_form = () => {
  const history = useHistory();
  //动态数据源
  const [dynDatasObject, setdynDatasObject] = useState({
    kfkhdaOptions: [], dict_qylx: [], dict_gyslx: [], dict_gj: [], dict_sf: [], dict_cs: [], dict_hzzt: [], dict_ghlx: [], dict_bslx: [], dict_zsmc: [], dict_zzmc: [],
    gys_cp: [], gys_mj: [], gd_mjmx: [], data_ejfl: [], dict_zlmc: []
  })
  const [isloading, setisloading] = useState(true)
  const [ghmxcolums, setghmxcolums] = useState(use_gys_ghmx_column_initformdata)
  const [ghmxdata, setghmxdata] = useState([])
  const [zzmxcolums, setzzmxcolums] = useState(use_gys_zzsz_column_initformdata)
  const [zzmxdata, setzzmxdata] = useState([])
  const [ghdelidarr, setghdelidarr] = useState([])
  const [zzdelidarr, setzzdelidarr] = useState([])
  // const [sqmxcolums, setsqmxcolums] = useState(use_gys_sqmx_column_initformdata)
  // const [sqmxdata, setsqmxdata] = useState([])
  // const [yhmxcolums, setyhmxcolums] = useState(use_gys_yhmx_column_initformdata)
  // const [yhmxdata, setyhmxdata] = useState([])
  // const [sqdelidarr, setsqdelidarr] = useState([])
  // const [yhdelidarr, setyhdelidarr] = useState([])
  const [kpmxcolums, setkpmxcolums] = useState(use_gys_kpmx_column_initformdata)
  const [kpmxdata, setkpmxdata] = useState([])
  const [kpdelidarr, setkpdelidarr] = useState([])
  const [isModalOpen, setIsModalOpen] = useState(false);
  const [blacklistReason, setBlacklistReason] = useState('');
  const [gysmcWarning, setGysmcWarning] = useState(''); // 供应商名称重名警告
  const dynDatasObjectRef = useLatest(dynDatasObject)
  const checkGysmcTimerRef = useRef(null); // 防抖定时器

  /**
   * 强制刷新明细表 用于特殊场景
   */
  const [switche, setswitche] = useState(true);
  const forceupdate = () => { setswitche(false) }
  useEffect(() => { switche ? "1" : setswitche(true) }, [switche])

  /**
   * 检查供应商名称是否存在（防抖）
   */
  const checkGysmcExist = useCallback(async (gysmc) => {
    if (!gysmc || gysmc.trim() === '') {
      setGysmcWarning('');
      return;
    }
    
    try {
      let rtdata = await fetchsync_util("/admin/gyszx/check_gysmc_exist", 'POST', { gysmc }, "json")
      if (rtdata.resultdata.exist) {
        setGysmcWarning('⚠️ 当前系统内已存在同名供应商，请修改！');
        message.warning('系统内已存在同名供应商！');
      } else {
        setGysmcWarning('');
      }
    } catch (error) {
      console.error('检查供应商名称失败:', error);
    }
  }, []);

  /**
   * 防抖处理供应商名称检查
   */
  const debouncedCheckGysmc = useCallback((gysmc) => {
    // 清除之前的定时器
    if (checkGysmcTimerRef.current) {
      clearTimeout(checkGysmcTimerRef.current);
    }
    
    // 设置新的定时器，500ms 后执行检查
    checkGysmcTimerRef.current = setTimeout(() => {
      checkGysmcExist(gysmc);
    }, 500);
  }, [checkGysmcExist]);

  const init = async () => {
    setisloading(true)
    var dictObj = await use_dict_byzdmc(["dict_qylx", "dict_gyslx", "dict_hzzt", "dict_ghlx", "dict_bslx", "dict_zsmc", "dict_zzmc", "dict_zlmc"])

    var bbObj = await use_olreport_bybbbm(["data_ejfl", "query_gys"])

    // console.log("当前插叙得到的query_ejfl为：", bbObj.data_ejfl)

    dynDatasObject.dict_qylx = dictObj.dict_qylx
    dynDatasObject.dict_gyslx = dictObj.dict_gyslx
    dynDatasObject.dict_hzzt = dictObj.dict_hzzt
    dynDatasObject.dict_ghlx = dictObj.dict_ghlx
    dynDatasObject.dict_bslx = dictObj.dict_bslx
    dynDatasObject.dict_zsmc = dictObj.dict_zsmc
    dynDatasObject.dict_zzmc = dictObj.dict_zzmc
    dynDatasObject.dict_zlmc = dictObj.dict_zlmc

    dynDatasObject.data_ejfl = bbObj.data_ejfl

    setdynDatasObject({ ...dynDatasObject })
    setisloading(false)
  }

  //主表数据
  const [formdata, setformdata] = useState(JSON.parse(storage.getItem("pre_gys_item")).type == "view" ? use_gys_view_initformdata : use_gys_initformdata)
  const { nowroute, setnowroute, collapsed, setcollapsed } = useStore();


  //加载主表数据
  const loadformdata = async (data) => {
    setisloading(true)
    let rtdata = await fetchsync_util("/admin/gyszx/query_gys_byid", 'POST', { data }, "json")
    console.log(rtdata.resultdata.formdata)
    rtdata.resultdata.formdata.zzyxqks = rtdata.resultdata.formdata.zzyxqks ? convertISODateTimeToYYYYMMDD(rtdata.resultdata.formdata.zzyxqks) : ""
    rtdata.resultdata.formdata.zzyxqjs = rtdata.resultdata.formdata.zzyxqjs ? convertISODateTimeToYYYYMMDD(rtdata.resultdata.formdata.zzyxqjs) : ""
    rtdata.resultdata.formdata.sfzyxqks = rtdata.resultdata.formdata.sfzyxqks ? convertISODateTimeToYYYYMMDD(rtdata.resultdata.formdata.sfzyxqks) : ""
    rtdata.resultdata.formdata.sfzyxqjs = rtdata.resultdata.formdata.sfzyxqjs ? convertISODateTimeToYYYYMMDD(rtdata.resultdata.formdata.sfzyxqjs) : ""
    setformdata({ ...formdata, ...resultdata_to_formdata(rtdata.resultdata.formdata, formdata) });
    setghmxdata(addkey_for_mxdata(rtdata.resultdata.ghmxdata))
    let dictObj = await use_dict_byzdmc(["dict_zlmc"])
    for (let i = 0; i < dictObj.dict_zlmc.length; i++) {
      if (!rtdata.resultdata.zzmxdata.some(item => item.zsmc == dictObj.dict_zlmc[i].label)) {
        rtdata.resultdata.zzmxdata.push({
          id: uuidv4(),
          mainid: rtdata.resultdata.formdata.id,
          zsmc: dictObj.dict_zlmc[i].label,
          zsbh: '',
          bfdw: '',
          yxqks: '',
          yxqjs: '',
          fjsc: ''
        })
      }
    }
    setzzmxdata(addkey_for_mxdata(rtdata.resultdata.zzmxdata.map(item => {
      item.yxqks = item.yxqks ? convertISODateTimeToYYYYMMDD(item.yxqks) : ""
      item.yxqjs = item.yxqjs ? convertISODateTimeToYYYYMMDD(item.yxqjs) : ""
      return item
    })))
    // setsqmxdata(addkey_for_mxdata(rtdata.resultdata.sqmxdata))
    // setyhmxdata(addkey_for_mxdata(rtdata.resultdata.yhmxdata))
    setkpmxdata(addkey_for_mxdata(rtdata.resultdata.kpmxdata.map(item => {
      item.kpzqq = item.kpzqq ? convertISODateTimeToYYYYMMDD(item.kpzqq) : ""
      item.kpzqz = item.kpzqz ? convertISODateTimeToYYYYMMDD(item.kpzqz) : ""
      return item
    })))
    setisloading(false)
  }

  //准入
  const handlezhunru = async () => {
    let rtdata = await fetchsync_util("/admin/gyszx/zhunru", 'POST', { formdata }, "json")
    rtdata.rtstatus ? openNotification_util(rtdata.rtmessage) : 1
    setformdata(rtdata.resultdata.formdata);

    dropByCacheKey('gyslb')
    dropByCacheKey('gys_form')
    setnowroute({ route: "/shipSRM/gyszx/gyslb", title: "供应商档案", closeroute: "/shipSRM/gyszx/gys_form" })
  }

  useEffect(() => {
    // 如果是edit模式，把供应商名称设置为只读
    if (JSON.parse(storage.pre_gys_item).type === "edit" && formdata && formdata.gysmc) {
      setformdata(prev => ({
        ...prev,
        gysmc: {
          ...prev.gysmc,
          inputType: "readonly"
        }
      }));
    }
    // eslint-disable-next-line
  }, [formdata.gysmc.value]);

  //拉黑
  const handlelhei = async () => {
    let rtdata = await fetchsync_util("/admin/gyszx/lhei", 'POST', { formdata, blacklistReason }, "json")
    rtdata.rtstatus ? openNotification_util(rtdata.rtmessage) : 1
    setformdata(rtdata.resultdata.formdata);
    setIsModalOpen(false);
    setBlacklistReason('');
    dropByCacheKey('gyslb')
    dropByCacheKey('gys_form')
    setnowroute({ route: "/shipSRM/gyszx/gyslb", title: "供应商档案", closeroute: "/shipSRM/gyszx/gys_form" })
  }

  const add = async () => {
    await init()
    if (storage.yhlx == "管理用户") {
      formdata.hzzt.disabled = false
    }
    for(let i=0;i<dynDatasObject.dict_zlmc.length;i++){
      if(!zzmxdata.some(item=>item.zsmc == dynDatasObject.dict_zlmc[i].label)){
        zzmxdata.push({
          id:uuidv4(),
          mainid:formdata.id,
          zsmc:dynDatasObject.dict_zlmc[i].label,
          zsbh:'',
          bfdw:'',
          yxqks:'',
          yxqjs:'',
          fjsc:''
        })
      }
    }
    setzzmxdata(addkey_for_mxdata(zzmxdata))
    setswitche(false)

    setkpmxcolums(view_item_util(use_gys_kpmx_column_initformdata()))
  }

  // 页面进入加载数据
  useEffect(() => {
    if (JSON.parse(storage.pre_gys_item).type == "edit") {
      init()
      loadformdata(JSON.parse(storage.pre_gys_item).data)
      setkpmxcolums(view_item_util(use_gys_kpmx_column_initformdata()))
      if (storage.yhlx == "管理用户") {
        formdata.hzzt.disabled = false
      }
    }
    else if (JSON.parse(storage.pre_gys_item).type == "add") {
      add()
    }
    else {
      loadformdata(JSON.parse(storage.pre_gys_item).data)
      setghmxcolums(view_item_util(use_gys_ghmx_column_initformdata()))
      // setsqmxcolums(view_item_util(use_gys_sqmx_column_initformdata()))
      // setyhmxcolums(view_item_util(use_gys_yhmx_column_initformdata()))
      setzzmxcolums(view_item_util(use_gys_zzsz_column_initformdata()))
      setkpmxcolums(view_item_util(use_gys_kpmx_column_initformdata()))
      setisloading(false)
    }
  }, [])


  //设置value
  const setfield = (onekey, value, settype) => {
    if (settype == 'single') {
      var newitem = formdata[onekey]
      newitem.value = value
      let newformdata = Object.assign({}, formdata, { [onekey]: newitem });
      setformdata(newformdata)
      
      // 如果是新增模式且修改的是供应商名称，触发重名检查
      if (onekey === 'gysmc' && JSON.parse(storage.pre_gys_item).type === "add") {
        debouncedCheckGysmc(value);
      }
    }
    else if (settype == "muti") {
      let [tansferarr, selectrow, newformdata] = [onekey, value, {}];
      tansferarr.forEach(item => {
        var newitem = formdata[item.target]
        newitem.value = selectrow ? selectrow[item.origin] : ""
        newformdata = Object.assign({}, formdata, { [item.target]: newitem });
      })
      setformdata(newformdata)
    }

  }

  //保存
  const handleupload = async () => {


    var checkobj = checkdatavalid_util_formdata(formdata)
    //主表字段校验没通过不能保存，目前没写子表校验。

    if (!checkobj.rtstatus) { openNotification_util(checkobj.rtmessage); return; }
    else;
    //拼接明细
    var newghmxdatalist = combile_mxdata_mxcol_util(ghmxdata, ghmxcolums)
    // var newsqmxdatalist = combile_mxdata_mxcol_util(sqmxdata, sqmxcolums)
    // var newyhmxdatalist = combile_mxdata_mxcol_util(yhmxdata, yhmxcolums)
    var newzzmxdatalist = combile_mxdata_mxcol_util(zzmxdata, zzmxcolums)
    var newkpmxdatalist = combile_mxdata_mxcol_util(kpmxdata, kpmxcolums)
    formdata.gyswhzt.value = "已维护"
    //设置submit url
    var uploadurl = JSON.parse(storage.pre_gys_item).type == "add" ?
      "/admin/gyszx/add_gys" : "/admin/gyszx/update_gys";
    let rtdata = await fetchsync_util(uploadurl, 'POST', {
      formdata,
      ghmxdata: newghmxdatalist,
      // sqmxdata: newsqmxdatalist,
      // yhmxdata: newyhmxdatalist,
      zzmxdata: newzzmxdatalist,
      kpmxdata: newkpmxdatalist,
      ghdelidarr: ghdelidarr,
      // sqdelidarr: sqdelidarr,
      // yhdelidarr: yhdelidarr,
      zzdelidarr: zzdelidarr,
      kpdelidarr: kpdelidarr
    }, "json")
    rtdata.rtstatus ? openNotification_util(rtdata.rtmessage) : 1
    setformdata(rtdata.resultdata.formdata);

    dropByCacheKey('gyslb')
    dropByCacheKey('gys_form')
    setnowroute({ route: "/shipSRM/gyszx/gyslb", title: "供应商档案", closeroute: "/shipSRM/gyszx/gys_form" })

  }
  //暂存 
  const handleZc = async () => {

    // var checkobj = checkdatavalid_util_formdata(formdata)
    // //主表字段校验没通过不能保存，目前没写子表校验。

    // if (!checkobj.rtstatus) { openNotification_util(checkobj.rtmessage); return; }
    // else;
    //拼接明细
    var newghmxdatalist = combile_mxdata_mxcol_util(ghmxdata, ghmxcolums)
    // var newsqmxdatalist = combile_mxdata_mxcol_util(sqmxdata, sqmxcolums)
    // var newyhmxdatalist = combile_mxdata_mxcol_util(yhmxdata, yhmxcolums)
    var newzzmxdatalist = combile_mxdata_mxcol_util(zzmxdata, zzmxcolums)
    var newkpmxdatalist = combile_mxdata_mxcol_util(kpmxdata, kpmxcolums)

    //设置submit url
    var uploadurl = JSON.parse(storage.pre_gys_item).type == "add" ?
      "/admin/gyszx/add_gys" : "/admin/gyszx/update_gys";
    let rtdata = await fetchsync_util(uploadurl, 'POST', {
      formdata,
      ghmxdata: newghmxdatalist,
      // sqmxdata: newsqmxdatalist,
      // yhmxdata: newyhmxdatalist,
      zzmxdata: newzzmxdatalist,
      kpmxdata: newkpmxdatalist,
      ghdelidarr: ghdelidarr,
      // sqdelidarr: sqdelidarr,
      // yhdelidarr: yhdelidarr,
      zzdelidarr: zzdelidarr,
      kpdelidarr: kpdelidarr
    }, "json")
    rtdata.rtstatus ? openNotification_util(rtdata.rtmessage) : 1
    setformdata(rtdata.resultdata.formdata);

    dropByCacheKey('gyslb')
    dropByCacheKey('gys_form')
    setnowroute({ route: "/shipSRM/gyszx/gyslb", title: "供应商档案", closeroute: "/shipSRM/gyszx/gys_form" })

  }


  const renderfileditem = () => {
    var formdataarr = []
    for (var formitemkey in formdata) {
      formdata[formitemkey].inputType == "none" ? "" : formdataarr.push(formdata[formitemkey])
    }
    var renderstr = formdataarr.map(item => {
      var rtitem = item.input_type == "space_item" ?
        <Customfielditem_hook form={formdata} item={{ inputType: "none" }}
          handlechange={(key, value, settype) => { setfield(key, value, settype) }} />
        :
        <Customfielditem_hook form={formdata} item={formdata[item.dataIndex]}
          dynDatasObject={dynDatasObject}
          handlechange={(key, value, settype) => { setfield(key, value, settype) }} />
      return rtitem
    }
    )
    return renderstr
  }

  return (

    <div style={{
      height: "94%", backgroundColor: `#F1F1F1`, right: "1%", top: "5.9vh", overflow: "hidden",
      backgroundSize: "100% 100%", width: collapsed ? "94%" : "84%", position: "absolute", color: "white", fontSize: "0.8rem"
    }}
    data-page-type="form">

      <div style={{width:"100%",height:"100%",backgroundColor:"white",overflow:"auto"}}>
      <div style={{
        width: "100%", height: "7%", position: "sticky", top: "1%", backgroundColor: "white", color: "black", display: "flex",
         zIndex: 105, borderBottom: "2px solid #a91f24"
      }}>


      <div style={{ width: "40%", textAlign: "left", paddingRight: "1rem", display: "flex", alignItems: "center", fontWeight: "600" }}>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          工具栏
        </div>

        <div style={{ width: "60%", textAlign: "right", paddingRight: "1rem" }}>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          {JSON.parse(storage.pre_gys_item).type != "view" && storage.yhlx == "管理用户" && formdata.hzzt.value == "准入中" &&
            <Popconfirm title={`确定准入吗？`} onConfirm={handlezhunru} okText="确定" cancelText="取消">
              <Button type="primary"
                style={{ width: "6rem", height: '1.7rem', fontSize: "0.7rem", borderRadius: "5px", marginTop: "0.2rem" }}>
                <AuditOutlined /> 准入
              </Button>
            </Popconfirm>
          }
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          {storage.yhlx == "管理用户" && JSON.parse(storage.pre_gys_item).type == "edit" && formdata.hzzt.value != "黑名单" && formdata.hzzt.value != "准入中" &&
            <Popconfirm title={`确定要拉黑该供应商吗？`} onConfirm={() => setIsModalOpen(true)} okText="确定" cancelText="取消">
              <Button type="default"
                style={{ width: "6rem", height: '1.7rem', fontSize: "0.7rem", borderRadius: "5px", marginTop: "0.2rem" }}>
                <DeleteColumnOutlined /> 拉黑
              </Button>
            </Popconfirm>
          }
          <Modal
            title="请输入拉黑原因"
            open={isModalOpen}
            onOk={handlelhei}
            onCancel={() => setIsModalOpen(false)}
          >
            <Input.TextArea
              rows={4}
              placeholder="请输入拉黑原因"
              value={blacklistReason}
              onChange={e => setBlacklistReason(e.target.value)}
            />
          </Modal>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          {JSON.parse(storage.pre_gys_item).type != "view" &&
            <Popconfirm title={`确定要提交吗？`} onConfirm={handleupload} okText="确定" cancelText="取消">
              <Button type="primary"
                style={{ width: "6rem", height: '1.7rem', fontSize: "0.7rem", borderRadius: "5px", marginTop: "0.2rem" }}>
                <SaveOutlined />提交
              </Button>
            </Popconfirm>
          }
          {JSON.parse(storage.pre_gys_item).type != "view" &&
            <Popconfirm title="确定要暂存吗？" onConfirm={handleZc} okText="确定" cancelText="取消">
              <Button type="default"
                style={{ width: "6rem", height: '1.7rem', fontSize: "0.7rem", borderRadius: "5px", marginTop: "0.2rem", marginLeft: "1rem" }}>
                <SaveOutlined />暂存
              </Button>
            </Popconfirm>
          }
        </div>

      </div>

      <div style={styles.kshcontainer}>
       <div style={{
          fontSize: "0.7rem", position: "relative", width: "98%", marginLeft: "1%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {renderfileditem()}
        </div>
        {/* 主表区域结束 */}
        <Divider></Divider>
        <div
          style={{
            height: "1.2rem",
            marginLeft: "2%",
            position: "relative",
            width: "96%",
            textIndent: "0.5rem",
            color: "#666666",
            backgroundColor: "white",
            lineHeight: "1.2rem",
            fontSize: "14px",
            fontWeight: "500",
            textAlign: "left",
            borderLeftStyle: "solid",
            borderWidth: "0.3rem",
            borderColor: "#a91f24",
            marginTop: "1rem",
            marginBottom: "0.5rem",
            letterSpacing: "0.05rem"
          }}
        >
          配套能力
        </div>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {isloading ?
            (<div style={{ width: "10%", height: "10%", position: "absolute", left: "50%", top: "49%", color: "#14d9cc" }}>            <LoadingOutlined /></div>)
            :
            <div style={{ position: "relative", width: "100%", overflowX: "auto", marginBottom: "1rem" }} data-detail-container="gys_ghmx">
              {switche && <Gys_ghmx_hook colmuns={ghmxcolums} datasource={ghmxdata}

                onepageheight="10vh"
                styleobj={{ height: "70%" }}
                dynDatasObject={dynDatasObject}
                formdata={formdata}
                handledelid={ids => { ids.length !== 0 ? setghdelidarr([...ghdelidarr, ...ids]) : ''; }}
                handgetmxdata={(tabledata) => {
                  addkey_for_mxdata(tabledata)
                  setghmxdata(tabledata)
                }}
                ifshowaddbtn={JSON.parse(storage.pre_gys_item).type != "view" ? true : false}
                handlechangeFormdata={(data) => {
                  setformdata(data)
                }}
                forceupdate={forceupdate}
              />}</div>
          }
         
        </div>
        <Divider></Divider>
        <div
          style={{
            height: "1.2rem",
            marginLeft: "2%",
            position: "relative",
            width: "96%",
            textIndent: "0.5rem",
            color: "#666666",
            backgroundColor: "white",
            lineHeight: "1.2rem",
            fontSize: "14px",
            fontWeight: "500",
            textAlign: "left",
            borderLeftStyle: "solid",
            borderWidth: "0.3rem",
            borderColor: "#a91f24",
            marginTop: "1rem",
            marginBottom: "0.5rem",
            letterSpacing: "0.05rem"
          }}
        >
          资质证书
        </div>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {isloading ?
            (<div style={{ width: "10%", height: "10%", position: "absolute", left: "50%", top: "49%", color: "#14d9cc" }}>            <LoadingOutlined /></div>)
            :
            <div style={{ position: "relative", width: "100%", overflowX: "auto", marginBottom: "1rem" }} data-detail-container="gys_zzmx">
              {switche && <Gys_zzmx_hook colmuns={zzmxcolums} datasource={zzmxdata}

                onepageheight="10vh"
                styleobj={{ height: "70%" }}
                dynDatasObject={dynDatasObject}
                formdata={formdata}
                handledelid={ids => { ids.length !== 0 ? setzzdelidarr([...zzdelidarr, ...ids]) : ''; }}
                handgetmxdata={(tabledata) => {
                  addkey_for_mxdata(tabledata)
                  setzzmxdata(tabledata)
                }}
                ifshowaddbtn={false}
                // ifshowaddbtn={JSON.parse(storage.pre_gys_item).type != "view" ? true : false}
                handlechangeFormdata={(data) => {
                  setformdata(data)
                }}
                forceupdate={forceupdate}
              />}</div>
          }


        </div>
        <Divider></Divider>
        <div
          style={{
            height: "1.2rem",
            marginLeft: "2%",
            position: "relative",
            width: "96%",
            textIndent: "0.5rem",
            color: "#666666",
            backgroundColor: "white",
            lineHeight: "1.2rem",
            fontSize: "14px",
            fontWeight: "500",
            textAlign: "left",
            borderLeftStyle: "solid",
            borderWidth: "0.3rem",
            borderColor: "#a91f24",
            marginTop: "1rem",
            marginBottom: "0.5rem",
            letterSpacing: "0.05rem"
          }}
        >
          考评历史
        </div>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {isloading ?
            (<div style={{ width: "10%", height: "10%", position: "absolute", left: "50%", top: "49%", color: "#14d9cc" }}>            <LoadingOutlined /></div>)
            :
            <div style={{ position: "relative", width: "100%", overflowX: "auto", marginBottom: "1rem" }} data-detail-container="gys_kpmx">
              {switche && <Gys_kpmx_hook colmuns={kpmxcolums} datasource={kpmxdata}

                onepageheight="10vh"
                styleobj={{ height: "70%" }}
                dynDatasObject={dynDatasObject}
                formdata={formdata}
                handledelid={ids => { ids.length !== 0 ? setkpdelidarr([...kpdelidarr, ...ids]) : ''; }}
                handgetmxdata={(tabledata) => {
                  addkey_for_mxdata(tabledata)
                  setkpmxdata(tabledata)
                }}
                ifshowaddbtn={false}
                handlechangeFormdata={(data) => {
                  setformdata(data)
                }}
                forceupdate={forceupdate}
              />}</div>
          }
        </div>

      </div>
      </div>
    </div>
  )
}


export default Gys_form
var styles = {
  maincontainer: {
    height: "100vh", backgroundColor: `white`,
    backgroundSize: "100% 100%", width: "100%", position: "absolute", left: "0", color: "white", fontSize: "0.8rem"
  },
  topcontainer: {
    width: "100%", height: "10vw", backgroundImage: "linear-gradient(to bottom,#e4e5eb , white)", paddingTop: "3vw",
    position: "relative", fontSize: "0.89rem", textIndent: "2rem", fontWeight: "800", color: "#a91f24", borderRadius: "0 0 15px 15px"
  },
  butdcstyle: { paddingLeft: "1vw", paddingRight: "1vw", height: "2vw", position: "absolute", right: "1%", top: "0%", backgroundColor: "#a91f24", fontSize: "0.8vw", borderRadius: "0.4rem", borderRadius: "0 0 0.3vw 0.3vw" },
  butmainstyle: { paddingLeft: "1vw", height: "2vw", position: "absolute", right: "6.5%", top: "0%", backgroundColor: "#a91f24", fontSize: "0.8vw", borderRadius: "0.4rem", borderRadius: "0 0 0.3vw 0.3vw" },
  butbackstyle: { borderRadius: "0.4rem", backgroundColor: "#a91f24", height: "2vw", position: "absolute", right: "12%", top: "0%", fontSize: "0.8vw", borderRadius: "0 0 0.3vw 0.3vw" },
  kshcontainer: {
    width: "98%", position: "relative", backgroundColor: "white", color: "#666",
    borderRadius: "10px", paddingBottom: "2rem", overflow: "visible"
  },
}